package com.whh.spring.ioc.beans.support;

import com.whh.spring.ioc.beans.BeanException;
import com.whh.spring.ioc.beans.config.BeanDefinition;

public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {
    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeanException("Bean 实例化失败",e);
        }
        addSingleton(beanName,bean);
        return bean;
    }
}
